import {defineConfig} from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import {ElementPlusResolver} from "unplugin-vue-components/resolvers";
import {createSvgIconsPlugin} from "vite-plugin-svg-icons";
import vueDevTools from "vite-plugin-vue-devtools";
import path, {resolve} from "path";

// https://vitejs.dev/config/
export default defineConfig({
    base: "./",
    server: {
        host: "0.0.0.0",
        port: 5175
    },
    plugins: [
        vueDevTools({
            // launchEditor: "VS Code"
        }),
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()],
        }),
        Components({
            resolvers: [ElementPlusResolver()],
        }),
        createSvgIconsPlugin({
            // 指定需要缓存的图标文件夹
            iconDirs: [path.resolve(process.cwd(), "src/icons")],
            // 指定symbolId格式
            symbolId: "icon-[dir]-[name]",

            /**
             * 自定义插入位置
             * @default: body-last
             */
            // inject?: 'body-last' | 'body-first'

            /**
             * custom dom id
             * @default: __svg__icons__dom__
             */
            // customDomId: '__svg__icons__dom__',
        }),
    ],
    resolve: {
        alias: {
            "@": resolve("src"),
        },
    },
    css: {},
});
